package com.cyz.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cyz.pojo.Page;
import com.cyz.pojo.Product;
import com.cyz.service.ProductService;
import com.cyz.service.impl.ProductServiceImpl;
import com.google.gson.Gson;

@Controller
@RequestMapping("/Paging")
public class Paging {
	
	@RequestMapping(value="/getProductPagingData")
	public void getProductPageData(HttpServletRequest request,HttpServletResponse response) throws IOException {
		PrintWriter printWriter = response.getWriter();
		Gson gson = new Gson();
		String typeName = request.getParameter("typeName");
		ProductServiceImpl productService = new ProductServiceImpl() ;
		List<Product> list = productService.getProductByTypeName(typeName);
		

		String s = gson.toJson(list);
		printWriter.write(s);
		printWriter.close();
	}
}
